<?php
//a session is started
session_start();
//The member ID stored in the session is retrieved
$member_id = $_SESSION['member_id'];

//specifies the connection to the server, as well as the username and password, and opens it
$con = mysql_connect("localhost", "root", "");

//if the connection wasnt opened, an sql error is returned
if (!$con) {

    ('Could not connect:' . mysql_error());
}

//the database being used is selected from the open connection
mysql_select_db("mydb", $con);
?>
<html>

    <head>
        <link rel="shortcut icon" type="image/x-icon" href="menu icons/favicon.ico">
        <meta http-equiv="X-UA-Compatible" content="IE=9" />
        <link href="style3.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
<!--        The title of the page and some descriptive information is printed-->
        <h1>General Options</h1>
        <h2>What would you like to do?</h2>
        <br>
        <?php 
        //a link is created redirecting to the edit information page, passing the memberID as a variable.
        echo '<a href="EditInfo.php?member_id=' . $member_id . '">Edit profile information</a>'; ?>
        <br>
        <br>
        <?php
        //a query is executed, retrieving all the conference records from the database which the logged in user has created
        $memConferences = mysql_query("SELECT conference_id, long_name FROM conference WHERE creator_id = '$member_id'");
        //If the query returns one or more rows, 
        if (mysql_num_rows($memConferences) > 0) {
            //a descriptive text is printed
            echo'<p style="text-decoration: underline">You are also an organizer in the following conference/s:</p>';
            //a list heading is printed
            echo '<ul>';
            //a loop iterates on all the records returned by the query, and stores them in an associative array.
            while ($row = mysql_fetch_array($memConferences, MYSQL_ASSOC)) {
                //a list item is printed, displaying the conference and a link which enables the user to edit information
                echo '<li>'.$row['long_name'].' &nbsp&nbsp&nbsp <a href="editconf.php?conference_id='.$row['conference_id'].'">Edit Information</a></li>';
            }
            //the list is closed
            echo '</ul>';
        }
        ?>
    </body>
</html>


